
#include <bits/stdc++.h>
#define PSI pair<string,int>
#define PII pair<int,int>
#define x first
#define y second
using namespace std;

const int N = 1e5 + 5;

int ans = INT_MAX;

void solve() {
    int N, A, B;
    cin >> N >> A >> B;

    vector<int> K(N + 2, 0), vis(N + 2, 0);

    for (int i = 1; i <= N; i++) {
        cin >> K[i];
    }

    queue<PII> q;
    q.push({A, 0}); 
    vis[A] = 1;

    while (q.size()) {
        int tx = q.front().x;
        int ty = q.front().y;
        q.pop();

        if (tx == B) {
            ans = ty;
            break;
        }

        if (tx + K[tx] > 0 && tx + K[tx] <= N && !vis[tx + K[tx]]) {
            q.push({tx + K[tx], ty + 1});
            vis[tx + K[tx]] = 1;
        }

        if (tx - K[tx] > 0 && tx - K[tx] <= N && !vis[tx - K[tx]]) {
            q.push({tx - K[tx], ty + 1});
            vis[tx - K[tx]] = 1;
        }
    }
    if (ans == INT_MAX) {
        cout << -1;
    } else {
        cout << ans;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
